//
//  HomeMenuViewController.m
//  ZhongWangYuanApp
//
//  Created by liuyingping on 2018/6/5.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "HomeMenuViewController.h"
#import "LPZWYCCTableHeaderView.h"
#import "LPZWYMenuHeaderView.h"
#import "LPZWYHomeMustTableViewCell.h"
#import "LPZWYCommonSpecilTableViewCell.h"
#import "LPZWYCommonClassTableViewCell.h"
/**  更多  */
#import "LPZWYChooseClassMoreClassViewController.h"
#import "LPZWYChooseClassMoreSpecalViewController.h"
#import "LPHomeOnAndUnderClassListViewController.h"
#import "LPHomeMenuSiJuJiMustListViewController.h"
#import "ZJVidoViewController.h"
#import "LPZWYChooseClassClassModel.h"
#import "YBProjectDetailViewController.h"
#import "YBHomeTopHeaderView.h"
#import "LPHomeMenuIndexDetailCourseListViewController.h"
#import "LPHomeMenuIndexDetailCourseClassViewController.h"
#import "FuncationCreatingLivingViewController.h"
#import "LPZWYSearchViewController.h"
#import "YBLoginViewController.h"
#import "SubjectViewController.h"
#import "ZJSubjectClassViewController.h"
#import "YBClassBasicInfoViewController.h"
#import "YBHomeBannerNewsViewController.h"
#define spicalCell @"LPZWYCommonSpecilTableViewCell"
#define classCell @"LPZWYCommonClassTableViewCell"
#define MustTable @"MustTableCell"
@interface HomeMenuViewController ()<UITableViewDelegate,UITableViewDataSource,LPZWYCCTableHeaderViewDelegate,LPZWYMenuHeaderViewDelegate,LPZWYHomeMustTableViewCellDelegate,YBHomeTopHeaderViewDelegate>
/**    */
@property (strong, nonatomic) UITableView  *tableView;
@property (nonatomic , copy) NSMutableArray * dataArray;
/** 滑动 */
@property (nonatomic, strong) ZJRefurbish *refurbish;
/**  页数  */
@property (assign, nonatomic) NSInteger  page;
/**  判断课程点击类型  */
@property (assign, nonatomic) NSInteger  classIndex;
/**    */
@property (strong, nonatomic) NSArray  *mustArray1;
/**  轮播图数组  */
@property (strong, nonatomic) NSArray  *wheelArray;
/**    */
@property (strong, nonatomic) YBHomeTopHeaderView  *headerView;
/**  判断是否是第一次进来  */
@property (assign, nonatomic) BOOL   isFirst;
/**    */
@property (strong, nonatomic) UITextField  *searchTextField;


@end

@implementation HomeMenuViewController


-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    if (!self.isFirst) {
        [self netWorking_header];
    }
}


-(void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [self.headerView.bannerView.bannerView ybSuspendTimer];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noticeObject:) name:NOTI_UPDATE_TAB object:nil];
    self.isFirst = YES;
    self.leftButton.hidden = YES;
    self.classIndex = 0;
    __weak typeof(self) weakSelf = self;
    [self.refurbish headerToScollview:self.tableView Block:^{
        weakSelf.page = 1;
        [self getWheelData];
        
    }];
     [self addHeader];
    [self getWheelData];
    [self addSearch];
    [self layoutUI];
    self.titlelabel.hidden = YES;
    
  
   
}

- (void)addSearch{
    UIView *backView = [UIView new];
    backView.layer.cornerRadius = 14;
    backView.layer.masksToBounds = YES;
    backView.backgroundColor = [UIColor whiteColor];
    [self.navigView addSubview:backView];
    backView.sd_layout
    .bottomSpaceToView(self.navigView, 8)
    .rightSpaceToView(self.navigView, 30 * [UIScreen zj_screenWScale])
    .heightIs(29)
    .leftSpaceToView(self.navigView, 30 * [UIScreen zj_screenWScale]);
    
    
    UIImageView *rightImageView = [UIImageView new];
    rightImageView.contentMode = UIViewContentModeCenter;
    rightImageView.image = [UIImage imageNamed:@"search"];
    rightImageView.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapLabel)];
    [rightImageView addGestureRecognizer:tap];
    [backView addSubview:rightImageView];
    rightImageView.sd_layout
    .rightEqualToView(backView)
    .centerYEqualToView(backView)
    .heightIs(29)
    .widthIs(50 * [UIScreen zj_screenWScale]);
    
    UITextField *searchLabel = [UITextField new];
    searchLabel.textColor = [UIColor textGrayColor];
    searchLabel.tintColor = [UIColor themeColor];
    searchLabel.font = LYPFONT(14);
    searchLabel.placeholder = @"     输入关键字";
    [searchLabel setValue:[NSNumber numberWithInt:20] forKey:@"paddingLeft"];
    [backView addSubview:searchLabel];
    self.searchTextField = searchLabel;
    searchLabel.sd_layout
    .centerYEqualToView(backView)
    .leftEqualToView(backView)
    .heightIs(29)
    .rightSpaceToView(rightImageView, 5 * [UIScreen zj_screenWScale]);
    if (YBUSERINFOMODEL.studentId.length == 0) {
        searchLabel.userInteractionEnabled = NO;
        rightImageView.userInteractionEnabled = NO;
    }
   
}

#pragma mark - 通知
- (void)noticeObject:(NSNotification *)noti{
    NSDictionary *dic = noti.object;
    if ([[dic objectForKey:@"index"] integerValue] == 0) {
        [self.tableView.mj_header beginRefreshing];
    }
}

/**  搜索点击事件  */
- (void)tapLabel{
    if (self.searchTextField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入需要搜索的课程" inview:[UIApplication sharedApplication].keyWindow];
        [self.searchTextField becomeFirstResponder];
        return;
    }
    LPZWYSearchViewController *vc = [LPZWYSearchViewController new];
    vc.searchString = self.searchTextField.text;
    vc.firstId = @"";
    vc.secondId = @"";
    vc.timeString = @"";
    [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];
    
}

- (void)getWheelData{
    if (self.isFirst) {
        [YJProgressHUD showMessage:@"加载中..." duration:10 view:[UIApplication sharedApplication].keyWindow];
    }
        [LPRequestManager request_getAllbannerImgForAppWithsuccessBlock:^(id object) {
            NSString *code = [object objectForKey:@"code"];
            if ([code integerValue] == 1) {
                self.wheelArray = [object objectForKey:@"data"];
                [self addHeader];
                [self netWorking_header];
            }else{
                [YJProgressHUD hide];
            }
        } failBlock:^(id object) {
            [YJProgressHUD hide];
        }];
   
}





#pragma mark - 数据
//下拉刷新
- (void)netWorking_header{
    self.tableView.userInteractionEnabled = NO;
    __weak typeof(self) weakSelf = self;
    [LPRequestManager request_GetPlanInClassListWithpageindex:0 pagesize:1   successBlock:^(id object) {
        NSString *result = [object objectForKey:@"code"];
        if ([result integerValue] == 1 ) {
           
            
             NSArray *array = @[@{@"title": @[@"网上专题班"], @"data": [NSArray yy_modelArrayWithClass:[LPZWYChooseClassClassModel class] json:[object objectForKey:@"data"]]}];
            
            [weakSelf getNew:array];
            self.tableView.userInteractionEnabled = YES;
            
        }else{
            [YJProgressHUD showSuccess:[object objectForKey:@"message"] inview:[UIApplication sharedApplication].keyWindow];
            [weakSelf.tableView.mj_header endRefreshing];
             [YJProgressHUD hide];
            self.tableView.userInteractionEnabled = YES;
        }
        
        if (self.isFirst == false) {
             [self.tableView.mj_header endRefreshing];
        }
        
    } failBlock:^(id object) {
         [YJProgressHUD hide];
        [weakSelf.tableView.mj_header endRefreshing];
        [YJProgressHUD showSuccess:@"网络错误" inview:[UIApplication sharedApplication].keyWindow];
        self.tableView.userInteractionEnabled = YES;
    }];
    
}

- (void)getOnAndOffLine:(NSArray *)array{
    NSMutableArray *newArray = [NSMutableArray array];
    [newArray addObjectsFromArray:array];
    __weak typeof(self) weakSelf = self;
    [LPRequestManager request_getIsOnLineAndOfflineClassListWithpageindex:0 pagesize:1 successBlock:^(id object) {
        NSString *code = [object objectForKey:@"code"];
        if ([code integerValue] == 1 && [object objectForKey:@"data"]) {
             NSArray *array = @[@{@"title": @[@"\"线上+线下\"专题"], @"data": [NSArray yy_modelArrayWithClass:[LPZWYChooseClassClassModel class] json:[object objectForKey:@"data"]]}];
            [newArray addObjectsFromArray:array];
        }else{

            [newArray addObjectsFromArray:@[]];
        }
        weakSelf.mustArray1 = [newArray mutableCopy];
        [weakSelf getNew:weakSelf.mustArray1];
        self.tableView.userInteractionEnabled = YES;
    } failBlock:^(id object) {
        [YJProgressHUD hide];
        [weakSelf.tableView.mj_header endRefreshing];
        [YJProgressHUD showSuccess:@"网络错误" inview:[UIApplication sharedApplication].keyWindow];
        self.tableView.userInteractionEnabled = YES;
    }];
}



- (void)getNew:(NSArray *)orangalArray{
    NSMutableArray *newArray = [NSMutableArray array];
    if (orangalArray.count == 0) {
        [newArray addObjectsFromArray:self.mustArray1];
    }else{
        [newArray addObjectsFromArray:orangalArray];
    }
    
    NSString *type;
    if (self.classIndex == 0) {
        type = @"1";
    }else if (self.classIndex == 1){
         type = @"2";
    }else{
         type = @"4";
    }
    __weak typeof(self) weakSelf = self;
    [LPRequestManager request_getcoursewarelistforwcateWithsearchType:type  pageindex:@"1" pagesize:@"5"  successBlock:^(id object) {
        NSString *result = [[object objectForKey:@"data"] objectForKey:@"result"];
        if ([result integerValue] == 1) {
            NSArray *array = [[object objectForKey:@"data"] objectForKey:@"list"];
//             [newArray addObject:@{@"title": @[@"最新课程", @"最热课程", @"推荐课程"], @"data": [NSArray yy_modelArrayWithClass:[LPZWYChooseClassClassModel class] json:array]}];
            [newArray insertObject:@{@"title": @[@"最新课程", @"最热课程", @"推荐课程"], @"data": [NSArray yy_modelArrayWithClass:[LPZWYChooseClassClassModel class] json:array]} atIndex:0];
            
            weakSelf.dataArray = newArray;
            [weakSelf.tableView reloadData];
            
            self.isFirst = false;
            
        }else{
            
            [YJProgressHUD showSuccess:[object objectForKey:@"message"] inview:[UIApplication sharedApplication].keyWindow];
        }
        
       [self.tableView.mj_header endRefreshing];
         [YJProgressHUD hide];
    } failBlock:^(id object) {
         [YJProgressHUD hide];
        [self.tableView.mj_header endRefreshing];
        [YJProgressHUD showSuccess:@"网络错误" inview:[UIApplication sharedApplication].keyWindow];
        
    }];
}

- (void)addHeader{
   
    if (self.wheelArray.count == 0) {
        [self.headerView setBannerArrayWithImageUrlArray:@[]];
    }else{
        NSMutableArray *urlStrings = [NSMutableArray array];
        for (NSDictionary *dic  in self.wheelArray) {
            [urlStrings addObject:[dic objectForKey:@"bannerimg_app"]];
        }
        [self.headerView setBannerArrayWithImageUrlArray:[urlStrings copy]];
    }
}

#pragma mark - 界面
- (void)layoutUI{
    [self.view addSubview:self.tableView];
    self.tableView.sd_layout
    .leftSpaceToView(self.view , 0)
    .rightSpaceToView(self.view , 0)
    .topSpaceToView(self.navigView , 0)
    .bottomSpaceToView(self.view , LP_TabBarHeight);
    YBHomeTopHeaderView *header = [[YBHomeTopHeaderView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], ItemHeight * 405)];
    header.delegate = self;
    self.tableView.tableHeaderView = header;
    self.headerView = header;
    
    
    
}


#pragma mark - YBHomeTopHeaderViewDelegate
- (void)didClickImageViewWithIndex:(NSInteger)index{
    
    if (YBUSERINFOMODEL.studentId.length == 0) {
        [self popLogin];
        return;
    }
    NSString * type = [self.wheelArray[index] objectForKey:@"category"];
    switch ([type integerValue]) {
        case 0:
        {
            //课程
            ZJVidoViewController *vc = [ZJVidoViewController new];
            LPZWYChooseClassClassModel *mdoel = [LPZWYChooseClassClassModel new];
            mdoel.ID = [self.wheelArray[index] objectForKey:@"coursewareid"];
            vc.model = mdoel;
            [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];
            break;
        }
        case 1:
        {
            //班级基本信息
            YBClassBasicInfoViewController *vc = [YBClassBasicInfoViewController new];
            vc.idString = [self.wheelArray[index] objectForKey:@"coursewareid"];
            [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];
            break;
        }
        case 2:
        {
            //其他
            ZJWebViewController *vc = [ZJWebViewController new];
            vc.urlString = [self.wheelArray[index] objectForKey:@"linkurl"];
            [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];
            break;
        }
        case 3:
        {
            //新闻
            YBHomeBannerNewsViewController *vc = [YBHomeBannerNewsViewController new];
            vc.idString = [self.wheelArray[index] objectForKey:@"coursewareid"];
            [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];
            break;
        }
            
        default:
            break;
    }
    
}

- (void)didClickBottomButtonWithIndex:(NSInteger)index{
    if (YBUSERINFOMODEL.studentId.length == 0) {
        [self popLogin];
        return;
    }
    switch (index) {
        case 0:
        {
            LPHomeMenuIndexDetailCourseListViewController *vc = [LPHomeMenuIndexDetailCourseListViewController new];
            [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];
        }
            break;
            
        case 1:
        {
            LPHomeMenuIndexDetailCourseClassViewController *vc = [LPHomeMenuIndexDetailCourseClassViewController new];
            [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];
        }
            break;
            
        case 2:
        {
            SubjectViewController *vc = [SubjectViewController new];
            vc.subTitle = @"学课";
            [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];

        }
            break;
            
        case 3:
        {
            /**  我的考试  */
            ZJWebViewController *vc = [ZJWebViewController new];
            vc.isHiddenNav = YES;
            vc.titleString = @"我的考试";
            vc.urlString = [NSString stringWithFormat:@"https://test.e-celap.com/appzwy/exam/#/?userid=%@&studentid=%@",YBUSERINFOMODEL.userid,YBUSERINFOMODEL.studentId];
            [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];
        }
            break;
            
        default:
            break;
    }
}

#pragma mark -LPZWYHomeMustTableViewCellDelegate

- (void)LPZWYHomeMustTableViewCell_clickViewIndex:(NSInteger)index section:(NSInteger)section{
    if (YBUSERINFOMODEL.studentId.length == 0) {
        [self popLogin];
        return;
    }
     NSArray *array = [self.dataArray[section] objectForKey:@"data"];
     [self clickApply:array[index] section:section index:index];
}

#pragma mark - UITableViewDataSource,UITableViewDelegate
/**  返回组个数  */
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.dataArray.count;
}
/**  返回cell个数  */
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    NSArray *array = [self.dataArray[section] objectForKey:@"data"];
    NSString *title = [self.dataArray[section] objectForKey:@"title"][0];
    return array.count;
}
/**  返回cell高度  */
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 125 * [UIScreen zj_screenHScale];
    
}
/**  cell初始化  */
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSArray *array = [self.dataArray[indexPath.section] objectForKey:@"data"];
    NSString *title = [self.dataArray[indexPath.section] objectForKey:@"title"][0];
    if ([title isEqualToString:@"网上专题班"] || [title isEqualToString:@"\"线上+线下\"专题"]) {

            LPZWYCommonSpecilTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:spicalCell forIndexPath:indexPath];
            cell.model = array[indexPath.row];
            cell.isShowEnd = 0;
            return cell;
    }else{
        LPZWYCommonClassTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:classCell forIndexPath:indexPath];
        cell.isMintue = YES;
        cell.model = array[indexPath.row];
        return cell;
    }
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 40 * [UIScreen zj_screenHScale];
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
     NSString *title = [self.dataArray[section] objectForKey:@"title"][0];
    if ([title isEqualToString:@"网上专题班"] || [title isEqualToString:@"\"线上+线下\"专题"]) {
        LPZWYCCTableHeaderView *header = [[LPZWYCCTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], 40 * [UIScreen zj_screenHScale])];
        header.section = section;
        header.headline.text = title;
        header.delegate = self;
        return header;
    }else{
        LPZWYMenuHeaderView *header = [[LPZWYMenuHeaderView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], 40 * [UIScreen zj_screenHScale]) titles:[self.dataArray[section] objectForKey:@"title"] index:self.classIndex];
        header.section = section;
        header.delegate = self;
        return header;
    }
  
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    TenGrayShadowView *ten = [[TenGrayShadowView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], 15 * [UIScreen zj_screenHScale])];
    return ten;
}



- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section{
    return 15 * [UIScreen zj_screenHScale];
}

- (void)scrollViewDidScroll:(UIScrollView*)scrollView {
    
    if (scrollView ==_tableView)
        
    {
        CGFloat sectionHeaderHeight = 40 * [UIScreen zj_screenHScale];
        CGFloat sectionFooterHeight = 15 * [UIScreen zj_screenHScale];
        CGFloat offsetY = scrollView.contentOffset.y;
        if (offsetY >= 0 && offsetY <= sectionHeaderHeight)
        {
            scrollView.contentInset = UIEdgeInsetsMake(-offsetY, 0, -sectionFooterHeight, 0);
        }else if (offsetY >= sectionHeaderHeight && offsetY <= scrollView.contentSize.height - scrollView.frame.size.height - sectionFooterHeight)
        {
            scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, -sectionFooterHeight, 0);
        }else if (offsetY >= scrollView.contentSize.height - scrollView.frame.size.height - sectionFooterHeight && offsetY <= scrollView.contentSize.height - scrollView.frame.size.height)
        {
            scrollView.contentInset = UIEdgeInsetsMake(-offsetY, 0, -(scrollView.contentSize.height - scrollView.frame.size.height - sectionFooterHeight), 0);
        }
    }
    
}

#pragma mark - LPZWYCCTableHeaderViewDelegate
- (void)LPZWYCCTableHeaderView_clickMore:(NSInteger)section{
    if (YBUSERINFOMODEL.studentId.length == 0) {
        [self popLogin];
        return;
    }
    NSString *title = [self.dataArray[section] objectForKey:@"title"][0];
    if ([title isEqualToString:@"网上专题班"] ) {
//        LPHomeMenuSiJuJiMustListViewController *vc =
//        [LPHomeMenuSiJuJiMustListViewController new];
//        [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];
        ZJSubjectClassViewController *vc = [ZJSubjectClassViewController new];
        vc.title = @"专题班";
        vc.isNOTaBVC = YES;
        [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];
        
    }else if ([title isEqualToString:@"\"线上+线下\"专题"]){
        LPHomeOnAndUnderClassListViewController *vc =
        [LPHomeOnAndUnderClassListViewController new];
        [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];
    }
}


#pragma mark - LPZWYMenuHeaderViewDelegate
- (void)LPZWYMenuHeaderView_clickTitleIndex:(NSInteger)index{
    self.classIndex = index;
    [self getNew:@[]];
}

- (void)LPZWYMenuHeaderView_clickMore:(NSInteger)section{
    if (YBUSERINFOMODEL.studentId.length == 0) {
        [self popLogin];
        return;
    }
    NSString *title = [self.dataArray[section] objectForKey:@"title"][self.classIndex];
    LPZWYChooseClassMoreClassViewController *vc =
    [LPZWYChooseClassMoreClassViewController new];
    vc.classType = title;
    [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];
}

#pragma mark - 报名
- (void)clickApply:(LPZWYChooseClassClassModel *)model section:(NSInteger)section index:(NSInteger)index{
        __weak typeof(self) weakSelf = self;
            
        [LPCustomClassObjTools classApplyWithClassid:model Success:^(id object) {
            model.appmainstatus = @"0";
            [self.dataArray[section] objectForKey:@"data"][index] = model;
            NSIndexPath *indexPath=[NSIndexPath indexPathForRow:index inSection:section];
            [weakSelf.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
            
        }];

}

/**  cell的点击事件  */
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (YBUSERINFOMODEL.studentId.length == 0) {
        [self popLogin];
        return;
    }
    NSArray *array = [self.dataArray[indexPath.section] objectForKey:@"data"];
    NSString *title = [self.dataArray[indexPath.section] objectForKey:@"title"][0];
    if ([title isEqualToString:@"网上专题班"] || [title isEqualToString:@"\"线上+线下\"专题"]) {
        
        [self clickApply:array[indexPath.row] section:indexPath.section index:indexPath.row];
    }else{
        if (YBUSERINFOMODEL.isCloudyAutonomouslyChooseStudy) {
            ZJVidoViewController *vc = [ZJVidoViewController new];
            NSArray *array = [self.dataArray[indexPath.section] objectForKey:@"data"];
            vc.model = array[indexPath.row];
            [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];
        }else{
            [YJProgressHUD showSuccess:@"您没有自主选学权限!" inview:[UIApplication sharedApplication].keyWindow];
        }
        
    }
    
}

#pragma mark - 懒加载
/**  初始化tableView  */
- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] init];
        _tableView.dataSource = self;
        _tableView.delegate = self;
        _tableView.backgroundColor = [UIColor themeGrayColor];
        _tableView.separatorColor = [UIColor clearColor];
        _tableView.tableFooterView = [UIView new];
        [_tableView registerClass:[LPZWYCommonClassTableViewCell class] forCellReuseIdentifier:classCell];
        [_tableView registerClass:[LPZWYCommonSpecilTableViewCell class] forCellReuseIdentifier:spicalCell];
        
         [_tableView registerClass:[LPZWYHomeMustTableViewCell class] forCellReuseIdentifier:MustTable];
         [_tableView adaptiveIOS11];
        
    }
    return _tableView;
}


- (NSMutableArray *)dataArray{
    if (_dataArray == nil) {
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}

- (ZJRefurbish *)refurbish{
    if (!_refurbish) {
        _refurbish = [ZJRefurbish new];
    }
    return _refurbish;
}


#pragma mark - 未登录状态
- (void)popLogin{
    __weak typeof(self) weakSelf = self;
    UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"请先登录" message:@"" preferredStyle:UIAlertControllerStyleAlert];
    [alertController addAction:[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        YBLoginViewController *vc = [YBLoginViewController new];
        [[ToolClass getMainNavigationController] pushViewController:vc animated:YES];
        
        
    }]];
    [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
    }]];
    [self presentViewController:alertController animated:YES completion:nil];
   
    
   
}

- (void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}


@end
